package com.vim.modules.mall.service.remote;

import com.vim.modules.mall.model.base.CommonPage;
import com.vim.modules.mall.model.base.MallResponseEntity;
import com.vim.modules.mall.model.mallSys.MallSysTask;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @作者 Administrator
 * @时间 2020-10-06 11:24
 * @版本 1.0
 */
@Service
@FeignClient(name = "web-gateway", contextId = "remoteMallSysTaskService", fallback = RemoteMallSysTaskServiceFallBack.class)
public interface RemoteMallSysTaskService {

    /**
     * 获取任务列表
     * @param pageNo 当前页码
     * @param pageSize 每页数量
     */
    @GetMapping("/adminApi/sys/task/taskList")
    MallResponseEntity<CommonPage<MallSysTask>> taskList(
            @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize
    );

    /**
     * 修改任务状态
     * @param taskId 任务id
     * @param status 状态（0停止 1启用）
     */
    @PostMapping("/adminApi/sys/task/taskCtrl")
    MallResponseEntity taskCtrl(
            @RequestParam(value = "taskId") Long taskId,
            @RequestParam(value = "status") String status
    );

    /**
     * 任务信息
     * @param taskId
     */
    @GetMapping("/adminApi/sys/task/taskInfo/{taskId}")
    MallResponseEntity<MallSysTask> taskInfo(@PathVariable(value = "taskId") Long taskId);

    /**
     * 任务保存
     * @param taskInfo  任务json串
     */
    @PostMapping("/adminApi/sys/task/taskSave")
    MallResponseEntity<MallSysTask> taskSave(String taskInfo);
}
